import {Component, OnInit} from '@angular/core';
import {BasePage} from '../../common/basePage';
import {NavController, ToastController} from '@ionic/angular';
import {HttpService} from '../../services/http.service';
import {ActivatedRoute} from '@angular/router';
import {UrlAndOPT} from '../../common/url-and-opt.enum';

/**
 * 标的信息－回款计划
 */
@Component({
  selector: 'app-bid-plan',
  templateUrl: './bid-plan.page.html',
  styleUrls: ['./bid-plan.page.scss'],
})
export class BidPlanPage extends BasePage implements OnInit {

  public dataList: any[] = [];

  constructor(public navCtrl: NavController,
              public toastCtrl: ToastController,
              private routeInfo: ActivatedRoute,
              private service$: HttpService
  ) {
    super(navCtrl, toastCtrl);
  }

  ngOnInit() {
    this.getDataList(this.routeInfo.snapshot.params['bidIdSign']);
  }

  /**
   * id: 70
   period: 1
   principalInterest: 8.33
   repaymentTime: 1536306000000
   status: "正常待还"
   totalPeriod: 3
   */
  // 获取投标记录列表 bidIdSign
  private getDataList(bidIdSign: string) {
    this.service$.doRequest(UrlAndOPT.bid_plan, {bidIdSign: bidIdSign})
      .subscribe(obj => {
        if (obj) {
          this.dataList = obj.records;
        }
      });
  }

}
